import {reqBannerList, reqCategoryList, reqFloorList} from '@/api'

const state = {
    categoryList: [],//初始化 []
    bannerList: [],
    floorList: []
}
const mutations = {
    RECEIVE_REQCATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList
    },
    RECEIVE_REQBANNERLIST(state, bannerList) {
        state.bannerList = bannerList
    },
    RECEIVE_REQFLOORLIST(state, floorList) {
        state.floorList = floorList
    }
}
const actions = {
    //commit是miniStore对象中的方法 这里结构赋值出来 直接使用
    async getCategoryList({commit}) {
        const result = await reqCategoryList()
        if (result.code === 200) {
            commit('RECEIVE_REQCATEGORYLIST', result.data)
        }
    },
    async getBannerList({commit}){
        const result= await reqBannerList()
        if (result.code===200){
            commit('RECEIVE_REQBANNERLIST',result.data)
        }
    },
    async getFloorList({commit}){
        const result=await reqFloorList()
        if (result.code===200){
            commit('RECEIVE_REQFLOORLIST',result.data)
        }
    }
}
const getters = {}
//对外暴露
export default {
    state,
    mutations,
    actions,
    getters
}